<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>显示隐藏密码</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }
        
        body {
            background: #DADBDC;
            position: relative;
        }
        
        #box {
            position: relative;
            margin: 0 auto;
            width: 640px;
            height: 350px;
            background: #fff;
            border-radius: 15px;
            text-align: center;
            margin-top: 167.576px;
        }
        
        .input_container {
            width: 290px;
            height: 38px;
            background: #fff;
            /* border: none; */
            line-height: 38px;
            font-size: 16px;
            padding-left: 30px;
        }
        
        .input_img {
            position: relative;
            top: 16px;
            left: -11px;
        }
        
        #eyes {
            position: relative;
            top: -30px;
            left: 133px;
        }
    </style>
</head>

<body>
    <div id="box">
        <H1>登录</H1>
        <br>
        <span style="text-align: center; color: #F87878;">请先登录以管理路由器</span>
        <br>
        <br>
        <img class="input_img" id="account_img" src="./img/account.jpg" height="38px" alt="">
        <input class="input_container" type="text" name="account" id="account" placeholder="请输入用户名" autocomplete="off">
        <br>
        <br>
        <img class="input_img" id="account_img" src="./img/authText.jpg" height="38px" alt="">
        <input class="input_container" type="password" name="authText" id="authText" placeholder="请输入密码" autocomplete="off">
        <br>
        <label for="authText" id="eyes"><img id="eyes_img" src="./img/close_eys.jpg" alt="" height="19px"></label>
    </div>
</body>

</html>

<script>
    // 获取页面元素
    let authText = window.document.querySelector('#authText');
    let eyes_img = window.document.querySelector('#eyes_img');
    // 页面元素绑定事件
    eyes_img.onclick = function() {
        let type = authText.type;
        // window.console.log(type);
        switch (type) {
            case 'text':
                // 修改页面元素属性
                authText.type = 'password';
                eyes_img.src = './img/close_eys.jpg';

                break;
            case 'password':

                // 修改页面元素属性
                authText.type = 'text';
                eyes_img.src = './img/open_eys.jpg';
                break;

            default:
                break;
        }
    };
</script>